/*
 * Copyright (c) 2024-2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


// WARNING! THIS FILE IS AUTO-GENERATED, DO NOT MAKE CHANGES, THEY WILL BE LOST ON NEXT GENERATION!

import { int32, float32 } from "@koalaui/common"
import { KStringPtr, KBoolean, RuntimeType, runtimeType, isResource, isInstanceOf } from "@koalaui/interop"
import { NodeAttach, remember } from "@koalaui/runtime"
import { ComponentBase } from "./ComponentBase"
import { TypeChecker } from "#components"
import { ArkCommonMethodComponent } from "./ArkCommon"
import { ArkAbilityComponentPeer } from "./peers/ArkAbilityComponentPeer"
import { UseEventsProperties } from "./use_properties"
import { CommonMethod } from "./ArkCommonInterfaces"
import { AbilityComponentAttribute } from "./ArkAbilityComponentInterfaces"
import { Callback_Void, Literal_Want_want } from "./SyntheticDeclarations"
import { Want } from "./ArkArkuiExternalInterfaces"
/** @memo:stable */
export class ArkAbilityComponentComponent extends ArkCommonMethodComponent {
    getPeer(): ArkAbilityComponentPeer {
        return (this.peer as ArkAbilityComponentPeer)
    }
    /** @memo */
    public setAbilityComponentOptions(value: Literal_Want_want): this {
        if (this.checkPriority("setAbilityComponentOptions")) {
            const value_casted = value as (Literal_Want_want)
            this.getPeer()?.setAbilityComponentOptionsAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public onConnect(value: (() => void)): this {
        if (this.checkPriority("onConnect")) {
            const value_casted = value as ((() => void))
            this.getPeer()?.onConnectAttribute(value_casted)
            return this
        }
        return this
    }
    /** @memo */
    public onDisconnect(value: (() => void)): this {
        if (this.checkPriority("onDisconnect")) {
            const value_casted = value as ((() => void))
            this.getPeer()?.onDisconnectAttribute(value_casted)
            return this
        }
        return this
    }
    public applyAttributesFinish(): void {
        // we calls this function outside of class, so need to make it public
        super.applyAttributesFinish()
    }
}

/** @memo */
export function ArkAbilityComponent(
  /** @memo */
  style: ((attributes: ArkAbilityComponentComponent) => void) | undefined,
  /** @memo */
  content_: (() => void) | undefined,
  value: Literal_Want_want
) {
    const receiver = remember(() => {
        return new ArkAbilityComponentComponent()
    })
    NodeAttach<ArkAbilityComponentPeer>((): ArkAbilityComponentPeer => ArkAbilityComponentPeer.create(receiver), (_: ArkAbilityComponentPeer) => {
        receiver.setAbilityComponentOptions(value)
        style?.(receiver)
        content_?.()
        receiver.applyAttributesFinish()
    })
}
